package com.lagou.demo03.servlet;

import com.lagou.demo03.service.StudentDelService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "StudentDelServlet", urlPatterns = "/studentDel")
public class StudentDelServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //获取需要删除的学生信息的学号
        String delId = request.getParameter("delId");
        System.out.println(delId);
        //创建StudentService类型的对象，实现数据的删除
        StudentDelService studentDelService = new StudentDelService();
        studentDelService.studentDelService(delId);
        //实现客户端跳转
        response.sendRedirect("student.jsp");
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request,response);
    }
}
